
GM.SpeedMultiplier = 200 -- Directional speed
GM.SpeedHandling = 0.5 -- Lerp contant for velocity

-- Returns number of checkpoints per lap.
function GM:GetNumCheckpoints()
	return syncvar.Get( "num_checkpoints" )
end

-- Returns number of laps in the race.
function GM:GetNumLaps()
	return syncvar.Get( "num_laps" )
end

function GM:IsWaiting()
	return syncvar.Get( "waiting" )
end

-- Returns a table of players competing in the current race.
function GM:GetAllRacers()
	-- If you plan to add a spectator mode or racing queue, this will be useful to edit.
	return player.GetAll()
end

-- Returns a vector representing the direction the player wants to go. Called from player_melon Think.
function GM:GetControlDirection( ply )
	local direction = Vector( 0, 0, 0 )
	local aimAng = ply:GetAimVector():Angle()
	if( ply:KeyDown( IN_FORWARD ) ) then
		//direction = direction + ( aimAng:Forward() )
	end
	if( ply:KeyDown( IN_BACK ) ) then
		//direction = direction + ( aimAng:Forward() * -1 )
	end
	if( ply:KeyDown( IN_MOVERIGHT ) ) then
		//direction = direction + aimAng:Right()
	end
	if( ply:KeyDown( IN_MOVELEFT ) ) then
		//direction = direction + ( aimAng:Right() * -1 )
	end
	return direction:Normalize()
end

-- Apply velocity to the melon. Called from player_melon Think.
function GM:ApplyMelonVelocity( melon, velocity )
	local phys = melon:GetPhysicsObject()
	if( not IsValid( melon ) or not IsValid( phys ) ) then return end
	phys:SetVelocity( velocity )
end
